﻿@using System.Timers

<div>
    <Button Type="primary" Loading>
        Loading
    </Button>
    <Button Type="primary" Size="small" Loading>
        Loading
    </Button>
    <br />
    <Button Type="primary" Loading="loading" OnClick=enterLoading>
        Click me!
    </Button>
    <Button
        Type="primary"
        Icon="poweroff"
    Loading="iconLoading"
    OnClick="enterIconLoading"
    >
    Click me!
    </Button>
</div>

@code
{
    bool loading = false;
    bool iconLoading = false;

    private void enterLoading()
    {
        loading = true;
        var timer = new Timer(8000);
        timer.Elapsed += (_, args) =>
        {
            loading = false;
            InvokeAsync(StateHasChanged);
        };
        timer.Start();
    }

    private void enterIconLoading()
    {
        iconLoading = true;
        var timer = new Timer(8000);
        timer.Elapsed += (_, args) =>
        {
            iconLoading = false;
            InvokeAsync(StateHasChanged);
        };
        timer.Start();
    }
}
